package f5transformation;

import flinkemp.Emp;
import flinkemp.EmpFun;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

//匿名类实现MapFunction接口，匿名类实现SourceFunction接口
public class Map1 {

    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<Emp> data = env.addSource(new EmpFun());
        data.print();
        SingleOutputStreamOperator<String> name = data.map(new MapFunction<Emp, String>() {
           @Override
           public String map(Emp emp) {
               return "姓名: "+emp.eName;
           }
        });
        name.print();
        env.execute();
    }
}
